package com.mentalhealthplatform.appModels;

import jakarta.persistence.*;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;
import org.springframework.data.elasticsearch.annotations.Mapping;

import java.util.Set;

@Entity
@Table(name = "test")
@Document(indexName = "test_es")
@Mapping(mappingPath = "test-mapping.json")
public class Test {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", nullable = false)
    private Integer id;

    @Field(type = FieldType.Text, analyzer = "ik_max_word", searchAnalyzer = "ik_smart")
    @Column(name = "topic", length = 255)
    private String topic;

    @Column(name = "always")
    private Boolean always;

    @Column(name = "often")
    private Boolean often;

    @Column(name = "sometimes")
    private Boolean sometimes;

    @Column(name = "hardly")
    private Boolean hardly;

    @Column(name = "none")
    private Boolean none;

    // 修改 type 为 Set<Integer>，表示多个类型
    @ElementCollection
    @CollectionTable(name = "test_types", joinColumns = @JoinColumn(name = "test_id"))
    @Column(name = "type")


    private Set<Integer> types;

    @Column(name = "status")
    private Integer status;

    // Getters and Setters
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public Boolean getAlways() {
        return always;
    }

    public void setAlways(Boolean always) {
        this.always = always;
    }

    public Boolean getOften() {
        return often;
    }

    public void setOften(Boolean often) {
        this.often = often;
    }

    public Boolean getSometimes() {
        return sometimes;
    }

    public void setSometimes(Boolean sometimes) {
        this.sometimes = sometimes;
    }

    public Boolean getHardly() {
        return hardly;
    }

    public void setHardly(Boolean hardly) {
        this.hardly = hardly;
    }

    public Boolean getNone() {
        return none;
    }

    public void setNone(Boolean none) {
        this.none = none;
    }

    public Set<Integer> getTypes() {
        return types;
    }

    public void setTypes(Set<Integer> types) {
        this.types = types;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }
}